<template>
<!--  TODO 通过链接访问协同文档 -->
<!--  之前的协同没有考虑链接访问,加了权限配置,改的话要动太多地方了,直接从新写一个,后期再合起来 -->
  <div v-if="isShow" style="height: 100%">
    <DocumentEditor
        id = "docEditor"
        :documentServerUrl = "serverUrl"
        :config = "config"
        :events_onDocumentReady = "onDocumentReady"
        :events_onRequestSharingSettings = "onRequestSharingSettings"
    />
  </div>

  <cooperate-authority v-model:dialog-drawer="cooperateVisible" :file-log-id="currentFileLogId" />
</template>

<script>
import {onMounted, reactive, ref, toRefs} from "vue";
import CooperateAuthority from "../components/CooperateAuthority.vue";
import {DocumentEditor} from "@onlyoffice/document-editor-vue";
import {useRouter} from "vue-router/dist/vue-router";

export default {
  name: "CollaborativeDocumentLink",
  components: {
    DocumentEditor,
    CooperateAuthority
  },
  setup(props, context) {
    const router = useRouter()

    const state = reactive({
      editor:null,
      isShow:false,
      cooperateVisible:false,
      config: {},
      serverUrl:import.meta.env.VITE_DOCUMENT_API_URL,
      currentFileLogId:null,
    })

    //加载完成回调
    const onDocumentReady = (editor) => {
      console.log("我准备好了")
      state.editor = editor;
    }
    //更改访问权限
    const onRequestSharingSettings = () => {

    }

    return{
      ...toRefs(state),
      DocumentEditor,
      CooperateAuthority,
      onDocumentReady,
      onRequestSharingSettings,

    }

  }

}
</script>

<style scoped>

</style>
